import logging
from sklearn.decomposition import PCA

def pca(weights, components):
    # def flatten_weights(weights):
    #     weight_vecs = []
    #     for _, weight in weights:
    #         weight_vecs.extend(weight.flatten())
    #     return weight_vecs

    # logging.info('Flattening weights...')
    # weight_vecs = [flatten_weights(weight) for weight in weights]
    pca = PCA(components)
    new_state = pca.fit_transform(weights)
    return new_state